{extend name="base" /} {block name="body"}
{block name="css"}
	<link rel="stylesheet" href="/public/oem/css/iconfont.css" />
	<link rel="stylesheet" href="/public/oem/css/css.css" />
{/block}
<div class="layui-body">
	<!--tab标签-->
	<div class="layui-tab layui-tab-brief">
		<ul class="layui-tab-title">
			<li class="layui-this">提现申请</li>
		</ul>
		<div class="layui-tab-content">
			<form class="layui-form layui-form-pane" action="{:url('finance/present')}" method="get">
				<div class="layui-inline">
					<label class="layui-form-label">关键词</label>
					<div class="layui-input-inline">
						<input type="text" name="keyword" value="{$keyword}" placeholder="请输入关键词" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<select name="ziduan">
						<option value="mobile" {if $ziduan=='mobile' }selected{/if}>会员账号</option>
						<option value="nick_name" {if $ziduan=='nick_name' }selected{/if}>会员昵称</option>
					</select>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">提现状态</label>
					<div class="layui-input-inline">
					      <select name="status"   class="layui-input">
					        <option value="4"></option>
							<option value="1">申请中</option>
							<option value="2">提现成功</option>
							<option value="3">提现失败</option>
					      </select>
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">排序</label>
					<div class="layui-input-inline">
						<select name="param">
							<option value="sq_time" {if $param=='create_time' }selected{/if}>申请时间</option>
						</select>
					</div>
				</div>
				<div class="layui-inline">
					<select name="sort">
						<option value="asc" {if $sort=='asc' }selected{/if}>从低到高</option>
						<option value="desc" {if $sort=='desc' }selected{/if}>从高到底</option>
					</select>
				</div>
				<div class="layui-inline">
					<button class="layui-btn">搜索</button>
				</div>
			</form>
			<hr>
			<table class="layui-table">
				<thead>
					<tr>
						<th>ID</th>
						<th>账号(手机号)</th>
						<th>昵称</th>
						<th>提现金额</th>
						<th>申请时间</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					{foreach name="tixian_list" item="vo"}
					<tr>
						<td>{$vo.id}</td>
						<td>{$vo.mobile}</td>
						<td>{$vo.nick_name}</td>
						<td>{$vo.money}</td>
						<td>{$vo.create_time}</td>
						<td>
							{if $vo.status==1}
							待审核
							{elseif $vo.status==2}
							申请成功
							{elseif $vo.status==3}
							申请失败
							{/if}
						</td>
						<td>
							{if $vo.status==1}
							<a href="#" onclick="shenghe({$vo.id});" class="layui-btn layui-btn-normal layui-btn-small">确认提现</a>
							<a href="#" onclick="bohui({$vo.id},{$vo.user_id});" class="layui-btn layui-btn-danger layui-btn-small ">驳回</a>
							{/if}
							<a href="#" onclick="record({$vo.user_id});" class="layui-btn layui-btn-danger layui-btn-small ">记录</a>
						</td>
					</tr>
					{/foreach}
				</tbody>
			</table>
			<!--分页-->
			{$tixian_list->render()}
		</div>
	</div>
</div>
{/block}
{block name="js"}

<script>
	// 定义全局JS变量
	var GV = {
		current_controller: "{$controller}/present"
	};
</script>
<script>
	//确认审核
	function shenghe(id) {
		var tiele = '';
		var lock = false; //默认未锁定
		layer.confirm('确认要审核通过吗？', {
			btn: ['确定', '取消'] //按钮
		}, function() {
			if(!lock) {
                lock = true; // 锁定
				$.ajax({
					type: 'post',
					url: "{:url('index/city/shenghe')}",
					dataType: 'json',
					data: {
						id: id,
						status:2
					},
					success: function(data) {
						if(data.code == 200) {
							layer.msg(data.msg, {
							  icon: 1,
							  time: 1000 //2秒关闭（如果不配置，默认是3秒）
							}, function(){
								location.href = "{:url('finance/present')}";
							});
						} else {
							layer.msg(data.msg, {
								icon: 1,
								time: 1000
							});
						}
					},
					error: function(data) {
						console.log(data.msg);
					}
				});
			}
		});
	}
	
	//驳回
	function bohui(id,user_id) {
		var tiele = '';
		layer.confirm('确认要审核驳回吗？', {
			btn: ['确定', '取消'] //按钮
		}, function() {
			$.ajax({
				type: 'post',
				url: "{:url('finance/bohui')}",
				dataType: 'json',
				data: {
					id: id,
					user_id: user_id
				},
				success: function(data) {
					if(data.code == 200) {
						layer.msg(data.msg, {
						  icon: 1,
						  time: 1000 //2秒关闭（如果不配置，默认是3秒）
						}, function(){
							location.href = "{:url('finance/present')}";
						});
					} else {
						layer.msg(data.msg, {
							icon: 1,
							time: 1000
						});
					}
				},
				error: function(data) {
					
				}
			});
		});
	}
	
	function record(user_id) {
		var url1 = 'show_yj?user_id=' + user_id;
		layer.open({
			type: 2,
			title: '佣金变化',
			shadeClose: true,
			shade: 0.8,
			area: ['775px', '500px'],
			content: [url1]
		});
	}
</script>
{/block}